<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
<!--    <meta charset="GBK">-->
<!--    <meta http-equiv="content-type" content="text/html" charset="GB2312">-->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>学生管理系统</title>
    <link rel="stylesheet" href="layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">学生管理系统</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a id="userName" href="javascript:;">
<!--                    <img id="userImg" src="" class="layui-nav-img">-->
                    <img id="userImg" src="">
                    贤心
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="">注销</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">个人信息</a>
                    <dl class="layui-nav-child">
                        <dd><a id="PersonalInformation" href="#">个人信息管理</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">班级信息</a>
                    <dl class="layui-nav-child">
                        <dd><a id="ClassInformation" href="#">班级信息管理</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>

    <!-- 内容主体区域 -->
    <div class="layui-body">
        <iframe name="child" style="width: 100%;height: 100%" id="content" src=""></iframe>
<!--        <div style="padding: 15px;">内容主体区域</div>-->
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © - 底部固定区域
    </div>
</div>



<script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.3.1/jquery.min.js"></script>
<script src="layui/layui.js"></script>
<script>
    $(function (){
        //个人信息
        $("#PersonalInformation").on('click',function () {
            $("#content").attr("src","PersonalInformation.html?stuNo="+getQueryVariable("stuNo"))
        })


        //班级信息
        $("#ClassInformation").on('click',function () {
            $("#content").attr("src","liststudents.html")
        })


        $.ajax({
            url:"/studentadminsystem/StudentMsgByStuNoServlet"
            ,type:"post"
            ,data:{
                No:getQueryVariable("stuNo")
            }
            ,cache: true
            ,success:function (data) {
                //判断是否为json格式
                if((typeof data=='object')&&data.constructor==Object){
                    obj=data;
                }else{
                    obj  = eval("("+data+")");
                }
                //alert(data)
                //alert(obj[0].stuNo)
                setPersonalInformation(obj)
            }
        })

        //JavaScript代码区域
        layui.use('element', function(){
            var element = layui.element;
        });
    });


    //获取个人信息
    function setPersonalInformation(obj) {
        $("#userImg").attr("src",obj[0].photoPath)//更新图片
        $("#userName").html(obj[0].stuName)//更新姓名
    }
    

    //获取当前页面url的参数
    function getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
        }
        return(false);
    }



</script>
</body>
</html>